package com.study.mapper.impl;

import com.study.entity.Student;
import com.study.mapper.StudentMapper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class StudentMapperImpl implements StudentMapper {
    private SqlSession session;

    public void setSqlSession(SqlSession session) {
        this.session = session;
    }

    @Override
    public List<Student> getAllStudent() {
        return session.selectList("com.study.mapper.StudentMapper.getAllStudent");
    }

    @Override
    public Student getStudentById(String id) {
        return session.selectOne("com.study.mapper.StudentMapper.getStudentById",id);
    }

    @Override
    public int addStudent(Student student) {
        return session.insert("com.study.mapper.StudentMapper.addStudent",student);
    }

    @Override
    public int updateStudent(Student student) {
        return session.update("com.study.mapper.StudentMapper.updateStudent",student);
    }

    @Override
    public int deleteStudentById(String id) {
        return session.delete("com.study.mapper.StudentMapper.deleteStudentById",id);
    }
}
